package io.renren.modules.back.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.UpdateGroup;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 普通用户
 *
 * @author zzh
 * @email 862583291@qq.com
 * @date 2018年12月8日 上午15:28:55
 */
@TableName("nideshop_user")
@Data
public class ShopUserEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @TableId(type = IdType.AUTO)
    @NotNull(message = "id不能为空", groups = {UpdateGroup.class})
    private Long userId;
    /**
     * 用户名
     */
    @NotBlank(message = "用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String username;
    /**
     * 用户密码
     */
    private String password;
    /**
     * 性别
     */
    @NotNull(message = "性别不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private Integer gender;
    /**
     * 出生日期
     */
    @Past(message = "日期格式错误", groups = {AddGroup.class, UpdateGroup.class})
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date birthday;
    /**
     * 最后登录时间
     */
    private Date lastLoginTime;
    /**
     * 最后登录Ip
     */
    private String lastLoginIp;
    /**
     * 用户等级
     */
    @NotNull(message = "用户等级不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private Integer userLevelId;
    /**
     * 昵称
     */
    private String nickname;
    /**
     * 手机号码
     */
    @NotBlank(message = "手机号码不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^1[0-9]{10}$", message = "手机格式错误", groups = {AddGroup.class, UpdateGroup.class})
    private String mobile;
    /**
     * 注册Ip
     */
    private String registerIp;
    /**
     * 头像url
     */
    private String avatar;
    /**
     * 微信Id
     */
    private String weixinOpenid;
    /**
     * 账户余额
     */
    private BigDecimal balanceFee;
    /**
     * 真实姓名
     */
    private String realname;
    /**
     * 身份证号
     */
    private String idcard;
    /**
     * 积分
     */
    private BigDecimal signFee;
    /**
     * 获取积分时间
     */
    private Date signTime;
    /**
     * 注册时间
     */
    private Date createTime;
    /**
     * 邮箱地址
     */
    @Email(message = "邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
    private String email;

    /**
     * 用户级别
     */
    @TableField(exist = false)
    private String levelName;
}
